The raw per-tile attribute byte at (x, y) in the current room’s collision tile layer - bits 0-1 are the mutually-exclusive tile class (see tile_class/TILE_PASS/TILE_SOLID/TILE_LOW_COVER), bits 2-7 are whatever a project itself gives them.
tile_flags(x, y) -> int| Name | Type |
|---|---|
x | real |
y | real |
int
The raw per-tile attribute byte at (x, y) in the current room's collision tile layer. Bits 0-1 are the mutually-exclusive tile class - TILE_PASS/TILE_SOLID/TILE_LOW_COVER, decoded by tile_class - and bits 2-7 are six bits a project names itself (hurtful, water, whatever a room's own tile layer needs). You name them in the Room Editor, and each name is also a word in your code: a flag called hurtful is FLAG_HURTFUL. See tile flags. tile_solid/tile_blocks_projectile already decode the class bits for the two questions most movement code actually asks; reach for tile_flags directly only when one of the project-defined bits matters too.
x and y are a place in the room, counted from the room's top-left corner. That is also where the tile grid starts, so the very first tile covers x from 0 to 7 and y from 0 to 7 (tiles are 8 by 8 pixels).
On a square with a shape, the flag bits count only where the shape is solid. A point in the empty part of a shaped square reads the class as usual but none of the six flag bits. A slope of poison grass that the player walks through is a row of Pass squares with a 45 degree shape and a flag called poison: tile_flags at the walker's feet reads the poison bit while the feet are in the grass, and does not in the air above it, in the same square. A full square (no shape) answers for every point, as it always did. See slopes.
A point outside the room reads as 0: TILE_PASS, no flags. The edge of a room is not a wall: a moving thing that reaches it keeps going and leaves the room. To keep things in, paint Solid collision along the edge, or check the position in code. A room with no tile layer at all has no map either, so every point there reads as 0 too.
var flags = tile_flags(x, y);
var standing_in_hazard = (flags & FLAG_HURTFUL) != 0;Reads the raw flag byte under the walker and records whether the flag called hurtful is set. FLAG_HURTFUL is the word for the tile flag you named hurtful: it is a plain number, 4 for the first flag you name, 8 for the next, and so on. The first two bits of the byte are always the tile class and are never a flag, which is why the first flag is 4 and not 1. You can also write the number yourself, like flags & 4, and the editor will list it as a bit your code uses, ready to be named. See tile flags.
On a square with a shape the six flag bits count only where the shape is solid: a point in the empty part reads the class but no flag bits (a slope of pass squares with a poison flag poisons the feet in the grass, not in the air above it). A square with no shape answers for every point. A point outside the room reads as 0 (TILE_PASS, no flags). The edge of a room is not a wall: a moving thing that reaches it keeps going and leaves the room. To keep things in, paint Solid collision along the edge, or check the position in code (room_left, room_right, room_top and room_bottom give the four edges). A room with no tile layer at all has no map either: every point reads as 0 (TILE_PASS, no flags) - checked on a real ROM.